import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/home/home.vue'
import Login from '../views/login/login.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: Home,
      children: [
        {
          path: 'bannerList',
          component: () => import('../views/bannerList/bannerList.vue'),
        },
        {
          path: 'bar',
          component: () => import('../views/charts/bar.vue')
        },
        {
          path: 'admin',
          component: () => import('../views/admin/admin.vue')
        },
        {
          path: 'proList',
          component: () => import('../views/pro/proList.vue')
        },
        {
          path: 'seckillList',
          component: () => import('../views/pro/seckillList.vue')
        },
        {
          path: 'recommendList',
          component: () => import('../views/pro/recommendList.vue')
        },
        {
          path: 'searchList',
          component: () => import('../views/pro/searchList.vue')
        }
      ]
    },
    {
      path: '/login',
      component: Login
    }
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (About.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import('../views/AboutView.vue')
    // }
    // 4.xx 没有*
  ]
})
// 4.xxx 多了一个非常好用的方法
// 添加1级路由
// router.addRoute({
//   path: '/about',
//   name: 'about',
//   component: () => import('../views/AboutView.vue')
// })
// 添加二级路由
// router.addRoute('about', {
//   path: '/child',
//   name: 'child',
//   component: () => import('../views/AboutView.vue')
// })
// 添加三级级路由
// router.addRoute('child', {
//   path: '/deepchild',
//   name: 'deepchild',
//   component: () => import('../views/AboutView.vue')
// })


export default router
